#include "stdafx.h"
#include "GraphicalActors.h"
#include "../environment/Map.hpp"

namespace graphicalactors
{
	GraphicalSpeedBrick::GraphicalSpeedBrick() :
		GraphicalGenerik()
	{

	}

	GraphicalSpeedBrick::~GraphicalSpeedBrick()
	{

	}

    void GraphicalSpeedBrick::init( irr::video::IVideoDriver * _driver, irr::scene::ISceneManager * _sceneManager, boost::uint8_t _baseAge )
    {
        m_age = _baseAge;

        GraphicalEntity * entity = NULL;
        entity = new GraphicalEntity();
        entity->init( _driver, _sceneManager, m_position, "../media/models/sphere.mesh", "../media/textures/head.bmp" );
        m_entities.push_back( entity );
        for ( boost::uint8_t i = 0; i < m_age; ++i )
        {
            entity = new GraphicalEntity();
            entity->init( _driver, _sceneManager, m_position, "../media/models/sphere.mesh", "../media/textures/yellow.bmp" );
            m_entities.push_back( entity );
        }
    }

    void GraphicalSpeedBrick::grow( int _newAge )
    {
        core::Application * currentApplication = core::Application::getCurrentApplication();
        irr::video::IVideoDriver * driver = currentApplication->getIrrlichtVideoDriver();
        irr::scene::ISceneManager * scnMgr = currentApplication->getIrrlichtSceneManager();
        GraphicalEntity * entity = NULL;

        for ( boost::uint8_t i = 0; i < (_newAge - m_age); ++i )
        {
            entity = new GraphicalEntity();
            entity->init( driver, scnMgr, m_position, "../media/models/sphere.mesh", "../media/textures/yellow.bmp" );
            m_entities.push_back( entity );
        }

        m_age = _newAge;
    }
}